#include <windows.h>
#include "resource.h"

#pragma comment(lib,"winmm.lib")

const char g_szClassName[] = "checkersHJW";

//UI variables
HWND g_hDialog = NULL;
HWND g_hwnd = NULL;
HBITMAP g_hbmImages = NULL;
HDC g_hdc = NULL, g_hdcMem = NULL;
HINSTANCE g_hInstance;
UINT mouse_x=0,mouse_y=0;

LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);
BOOL CALLBACK AboutProc(HWND,UINT,WPARAM,LPARAM);
BOOL CALLBACK OptionsProc(HWND, UINT, WPARAM, LPARAM);
BOOL CALLBACK SettingProc(HWND, UINT, WPARAM, LPARAM);
void createOptionDialog(HWND);
void createSettingDialog(HWND);

void inputProcess(HWND,UINT,UINT);
void paint(HDC);
void paintBoard();
void paintHover();
void paintStatus();

//DRAW FUNCTIONS
void drawBackground(int,int);
void drawSettingButton(int,int);
void drawSettingButtonClicked(int,int);
void drawP1turn(int,int);
void drawP2turn(int,int);
void drawP1win(int,int);
void drawP2win(int,int);
void drawOptionButton(int,int);
void drawOptionButtonClicked(int,int);
void drawNewGameButton(int,int);
void drawNewGameButtonClicked(int,int);
void drawAboutButton(int,int);
void drawAboutButtonClicked(int,int);

//Normal American
void drawNextTargetAmerican(int,int);
void drawBlackSquareAmerican(int,int);
void drawBlackSquareAmericanClicked(int,int);
void drawWhiteSquareAmerican(int,int);
void drawWhiteSquareAmericanClicked(int,int);
void drawRedAmerican(int,int);
void drawRedAmericanClicked(int,int);
void drawRedKingAmerican(int,int);
void drawRedKingAmericanClicked(int,int);
void drawWhiteAmerican(int,int);
void drawWhiteAmericanClicked(int,int);
void drawWhiteKingAmerican(int,int);
void drawWhiteKingAmericanClicked(int,int);

//Normal English
void drawNextTargetEnglish(int,int);
void drawBlackSquareEnglish(int,int);
void drawBlackSquareEnglishClicked(int,int);
void drawWhiteSquareEnglish(int,int);
void drawWhiteSquareEnglishClicked(int,int);
void drawRedEnglish(int,int);
void drawRedEnglishClicked(int,int);
void drawRedKingEnglish(int,int);
void drawRedKingEnglishClicked(int,int);
void drawWhiteEnglish(int,int);
void drawWhiteEnglishClicked(int,int);
void drawWhiteKingEnglish(int,int);
void drawWhiteKingEnglishClicked(int,int);

//Transformer American
void drawNextTargetTransAmerican(int,int);
void drawBlackSquareTransAmerican(int,int);
void drawBlackSquareTransAmericanClicked(int,int);
void drawWhiteSquareTransAmerican(int,int);
void drawWhiteSquareTransAmericanClicked(int,int);
void drawRedTransAmerican(int,int);
void drawRedTransAmericanClicked(int,int);
void drawRedKingTransAmerican(int,int);
void drawRedKingTransAmericanClicked(int,int);
void drawWhiteTransAmerican(int,int);
void drawWhiteTransAmericanClicked(int,int);
void drawWhiteKingTransAmerican(int,int);
void drawWhiteKingTransAmericanClicked(int,int);

//Transformer English
void drawNextTargetTransEnglish(int,int);
void drawBlackSquareTransEnglish(int,int);
void drawBlackSquareTransEnglishClicked(int,int);
void drawWhiteSquareTransEnglish(int,int);
void drawWhiteSquareTransEnglishClicked(int,int);
void drawRedTransEnglish(int,int);
void drawRedTransEnglishClicked(int,int);
void drawRedKingTransEnglish(int,int);
void drawRedKingTransEnglishClicked(int,int);
void drawWhiteTransEnglish(int,int);
void drawWhiteTransEnglishClicked(int,int);
void drawWhiteKingTransEnglish(int,int);
void drawWhiteKingTransEnglishClicked(int,int);

//Space American
void drawNextTargetSpaceAmerican(int,int);
void drawBlackSquareSpaceAmerican(int,int);
void drawBlackSquareSpaceAmericanClicked(int,int);
void drawWhiteSquareSpaceAmerican(int,int);
void drawWhiteSquareSpaceAmericanClicked(int,int);
void drawRedSpaceAmerican(int,int);
void drawRedSpaceAmericanClicked(int,int);
void drawRedKingSpaceAmerican(int,int);
void drawRedKingSpaceAmericanClicked(int,int);
void drawWhiteSpaceAmerican(int,int);
void drawWhiteSpaceAmericanClicked(int,int);
void drawWhiteKingSpaceAmerican(int,int);
void drawWhiteKingSpaceAmericanClicked(int,int);

//Space English
void drawNextTargetSpaceEnglish(int,int);
void drawBlackSquareSpaceEnglish(int,int);
void drawBlackSquareSpaceEnglishClicked(int,int);
void drawWhiteSquareSpaceEnglish(int,int);
void drawWhiteSquareSpaceEnglishClicked(int,int);
void drawRedSpaceEnglish(int,int);
void drawRedSpaceEnglishClicked(int,int);
void drawRedKingSpaceEnglish(int,int);
void drawRedKingSpaceEnglishClicked(int,int);
void drawWhiteSpaceEnglish(int,int);
void drawWhiteSpaceEnglishClicked(int,int);
void drawWhiteKingSpaceEnglish(int,int);
void drawWhiteKingSpaceEnglishClicked(int,int);

//Game Options Constants
const int AMERICAN = 0;
const int ENGLISH = 1;
const int PVP = 0;
const int PVC = 1;
const int CVC = 2;
const int SLOW = 0;
const int NORMAL = 1;
const int FAST = 2;
const int NONE = -1;
const int PIRATE = 0;
const int TRANSFORMER = 1;
const int SPACE = 2;
const int GREEDYBYEATING = 0;
const int GREEDYBYKING = 1;
const int EMPTY = 0;
const int WHITE = 1;
const int RED = 2;
const int WHITEKING = 3;
const int REDKING = 4;
const int PLAYER1 = 0;
const int PLAYER2 = 1;

//Game Options Variables
int board_x = 11, board_y = 11;
int gameMode=PVC; //0=PvsP, 1=PvsC, 2=CvsC
int gameRule=AMERICAN; //0=International/American, 1=English, English 8x8, American 10x10
int gameSpeed=NORMAL; //0=slow, 1=normal, 2=fast
int gameTheme=PIRATE; //0=normal, 1=trans, 2=space
int gameSound=PIRATE; //0=normal, 1=trans, 2=space
int gameAlgorithm=GREEDYBYEATING;
int gameTurn=PLAYER1;
int gameWin=NONE;
bool isSoundOn=true;
int temp_gameMode=gameMode;
int temp_gameRule=gameRule;
int temp_gameSpeed=gameSpeed;
int temp_gameAlgorithm=gameAlgorithm;
int temp_gameTheme=gameTheme;
int temp_gameSound=gameSound;
bool temp_isSoundOn=true;

//dummy
struct Square {
  bool chequered;
  int piece; //0=empty, 1=white, 2=red, 3=whiteking, 4=redking
  bool isNextTarget;
};
Square board[10][10];

//initiation
void initiateMusic();
void initiatedummy();

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
	LPSTR lpCmdLine, int nCmdShow)
{
	WNDCLASSEX wc;
	HWND hwnd;
	MSG msg;

	g_hInstance = hInstance;

	wc.cbSize		 = sizeof(WNDCLASSEX);
	wc.style		 = 0;
	wc.lpfnWndProc	 = WndProc;
    wc.cbClsExtra    = 0;
    wc.cbWndExtra    = 0;
    wc.hInstance     = hInstance;
	wc.hIcon         = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON1));
    wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
    wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
    wc.lpszMenuName  = NULL;
    wc.lpszClassName = g_szClassName;
    wc.hIconSm       = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON1));

	if(!RegisterClassEx(&wc))
    {
        MessageBox(NULL, "Window Registration Failed!", "Error!",
            MB_ICONEXCLAMATION | MB_OK);
        return 0;
    }

	hwnd = CreateWindowEx(
        WS_EX_CLIENTEDGE,
        g_szClassName,
        "Checkers HJW",
        WS_OVERLAPPED | WS_MINIMIZEBOX | WS_SYSMENU,
        GetSystemMetrics(SM_CXSCREEN)/2-405, GetSystemMetrics(SM_CYSCREEN)/2-315, 810, 630,
        NULL, NULL, hInstance, NULL);
	
	if(hwnd == NULL)
    {
        MessageBox(NULL, "Window Creation Failed!", "Error!",
            MB_ICONEXCLAMATION | MB_OK);
        return 0;
    }
	
	ShowWindow(hwnd, nCmdShow);
	UpdateWindow(hwnd);

	while(GetMessage(&msg,NULL,0,0)>0){
		TranslateMessage(&msg);
		DispatchMessage(&msg);
	}
	return msg.wParam;
}

LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	switch(msg)
    {
	case WM_CREATE:
	{
		g_hbmImages = LoadBitmap(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_BITMAP1));
			if(g_hbmImages == NULL)
				MessageBox(hwnd, "Could not load IDB_BALL!", "Error", MB_OK | MB_ICONEXCLAMATION);
		g_hwnd = hwnd;
		initiatedummy();
	}
		break;
	case WM_PAINT:
		{
			BITMAP bm;
			PAINTSTRUCT ps;

			g_hdc = BeginPaint(hwnd, &ps);
			GetObject(g_hbmImages, sizeof(bm), &bm);
			paint(g_hdc);
			EndPaint(hwnd, &ps);
		}
		break;
	case WM_LBUTTONUP:
		inputProcess(hwnd,LOWORD(lParam),HIWORD(lParam));
		if(gameTurn==PLAYER1) gameTurn=PLAYER2; else gameTurn=PLAYER1;
		InvalidateRect(hwnd, NULL, false);
        UpdateWindow(hwnd);
		break;
	case WM_MOUSEMOVE:
		mouse_x = LOWORD(lParam);
		mouse_y = HIWORD(lParam);
		if(mouse_x>600){
			InvalidateRect(hwnd, NULL, false);
			UpdateWindow(hwnd);
		}
		break;
    case WM_CLOSE:
        DestroyWindow(hwnd);
        break;
    case WM_DESTROY:
		KillTimer(hwnd, ID_TIMER);
		DeleteObject(g_hbmImages);
        PostQuitMessage(0);
        break;
    default:
        return DefWindowProc(hwnd, msg, wParam, lParam);
    }
    return 0;
}

void inputProcess(HWND hwnd, UINT x, UINT y){
	//BOARD LISTENER
	if(x<600 && y<600){
		if(gameRule==AMERICAN){
			board_x = (int) x/60;
			board_y = (int) y/60;
		} else {
			board_x = (int) x/75;
			board_y = (int) y/75;
		}
	}

	for(int i=0; i<10; i++){
		for(int j=0; j<10; j++){
			board[i][j].isNextTarget = false;
		}
	}

	if(board_y>0)
		board[board_x][board_y-1].isNextTarget = true;
	else
		board[board_x][board_y+1].isNextTarget = true;

	//SIDEBAR LISTENER
	if(610<x && x<790){
		//New Game
		if(10<y && y<90){initiatedummy();}
		//Options
		if(100<y && y<180 && g_hDialog==NULL){createOptionDialog(hwnd);}
		//Setting
		if(190<y && y<270 && g_hDialog==NULL){createSettingDialog(hwnd);}
		//About
		if(510<y && y<590 && g_hDialog==NULL){DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_ABOUT), hwnd, AboutProc);}
	}
}

void paint(HDC hdc){
	g_hdcMem = CreateCompatibleDC(g_hdc);
	HBITMAP hbmOld = (HBITMAP)SelectObject(g_hdcMem, g_hbmImages);
	paintBoard();
	drawBackground(600,0);
	paintHover();
	paintStatus();
	SelectObject(g_hdcMem, hbmOld);
	DeleteDC(g_hdcMem);
}

void paintBoard(){
	if(gameRule==AMERICAN){
		for(int i=0; i<10; i++){
			for(int j=0; j<10; j++){
				if(i!=board_x || j!=board_y){
					switch(board[i][j].piece){
					case EMPTY:
						if(board[i][j].chequered){
							switch(gameTheme){
							case PIRATE:
								drawBlackSquareAmerican(i*60, j*60);
								break;
							case TRANSFORMER:
								drawBlackSquareTransAmerican(i*60, j*60);
								break;
							case SPACE:
								drawBlackSquareSpaceAmerican(i*60, j*60);
								break;
							}
						}
						else{
							switch(gameTheme){
							case PIRATE:
								drawWhiteSquareAmerican(i*60, j*60);
								break;
							case TRANSFORMER:
								drawWhiteSquareTransAmerican(i*60, j*60);
								break;
							case SPACE:
								drawWhiteSquareSpaceAmerican(i*60, j*60);
								break;
							}
						}
						break;
					case WHITE:{
							switch(gameTheme){
							case PIRATE:
								drawWhiteAmerican(i*60, j*60);
								break;
							case TRANSFORMER:
								drawWhiteTransAmerican(i*60, j*60);
								break;
							case SPACE:
								drawWhiteSpaceAmerican(i*60, j*60);
								break;
							}
						}
						break;
					case RED:{
							switch(gameTheme){
							case PIRATE:
								drawRedAmerican(i*60, j*60);
								break;
							case TRANSFORMER:
								drawRedTransAmerican(i*60, j*60);
								break;
							case SPACE:
								drawRedSpaceAmerican(i*60, j*60);
								break;
							}
						}
						break;
					case WHITEKING:{
							switch(gameTheme){
							case PIRATE:
								drawWhiteKingAmerican(i*60, j*60);
								break;
							case TRANSFORMER:
								drawWhiteKingTransAmerican(i*60, j*60);
								break;
							case SPACE:
								drawWhiteKingSpaceAmerican(i*60, j*60);
								break;
							}
						}
						break;
					case REDKING:{
							switch(gameTheme){
							case PIRATE:
								drawRedKingAmerican(i*60, j*60);
								break;
							case TRANSFORMER:
								drawRedKingTransAmerican(i*60, j*60);
								break;
							case SPACE:
								drawRedKingSpaceAmerican(i*60, j*60);
								break;
							}
						}
						break;
					}
					if(board[i][j].isNextTarget){
						switch(gameTheme){
						case PIRATE:
							drawNextTargetAmerican(i*60, j*60);
							break;
						case TRANSFORMER:
							drawNextTargetTransAmerican(i*60, j*60);
							break;
						case SPACE:
							drawNextTargetSpaceAmerican(i*60, j*60);
							break;							
						}
					}					
				}
			}
		}
		switch(board[board_x][board_y].piece){
			case EMPTY:
				if(board[board_x][board_y].chequered){
					switch(gameTheme){
					case PIRATE:
						drawBlackSquareAmericanClicked(board_x*60,board_y*60);
						break;
					case TRANSFORMER:
						drawBlackSquareTransAmericanClicked(board_x*60,board_y*60);
						break;
					case SPACE:
						drawBlackSquareSpaceAmericanClicked(board_x*60,board_y*60);
						break;
					}
				}
				else{
					switch(gameTheme){
					case PIRATE:
						drawWhiteSquareAmericanClicked(board_x*60,board_y*60);
						break;
					case TRANSFORMER:
						drawWhiteSquareTransAmericanClicked(board_x*60,board_y*60);
						break;
					case SPACE:
						drawWhiteSquareSpaceAmericanClicked(board_x*60,board_y*60);
						break;
					}
				}
				break;
			case WHITE:{
					switch(gameTheme){
					case PIRATE:
						drawWhiteAmericanClicked(board_x*60,board_y*60);
						break;
					case TRANSFORMER:
						drawWhiteTransAmericanClicked(board_x*60,board_y*60);
						break;
					case SPACE:
						drawWhiteSpaceAmericanClicked(board_x*60,board_y*60);
						break;
					}
				}
				break;
			case RED:{
					switch(gameTheme){
					case PIRATE:
						drawRedAmericanClicked(board_x*60,board_y*60);
						break;
					case TRANSFORMER:
						drawRedTransAmericanClicked(board_x*60,board_y*60);
						break;
					case SPACE:
						drawRedSpaceAmericanClicked(board_x*60,board_y*60);
						break;
					}
				}
				break;
			case WHITEKING:{
					switch(gameTheme){
					case PIRATE:
						drawWhiteKingAmericanClicked(board_x*60,board_y*60);
						break;
					case TRANSFORMER:
						drawWhiteKingTransAmericanClicked(board_x*60,board_y*60);
						break;
					case SPACE:
						drawWhiteKingSpaceAmericanClicked(board_x*60,board_y*60);
						break;
					}
				}
				break;
			case REDKING:{
					switch(gameTheme){
					case PIRATE:
						drawRedKingAmericanClicked(board_x*60,board_y*60);
						break;
					case TRANSFORMER:
						drawRedKingTransAmericanClicked(board_x*60,board_y*60);
						break;
					case SPACE:
						drawRedKingSpaceAmericanClicked(board_x*60,board_y*60);
						break;
					}
				}
				break;
		}
	} else {
		for(int i=0; i<8; i++){
			for(int j=0; j<8; j++){
				if(i!=board_x || j!=board_y){
					switch(board[i][j].piece){
					case EMPTY:
						if(board[i][j].chequered){
							switch(gameTheme){
							case PIRATE:
								drawBlackSquareEnglish(i*75, j*75);
								break;
							case TRANSFORMER:
								drawBlackSquareTransEnglish(i*75, j*75);
								break;
							case SPACE:
								drawBlackSquareSpaceEnglish(i*75, j*75);
								break;
							}
						}
						else{
							switch(gameTheme){
							case PIRATE:
								drawWhiteSquareEnglish(i*75, j*75);
								break;
							case TRANSFORMER:
								drawWhiteSquareTransEnglish(i*75, j*75);
								break;
							case SPACE:
								drawWhiteSquareSpaceEnglish(i*75, j*75);
								break;
							}
						}
						break;
					case WHITE:{
							switch(gameTheme){
							case PIRATE:
								drawWhiteEnglish(i*75, j*75);
								break;
							case TRANSFORMER:
								drawWhiteTransEnglish(i*75, j*75);
								break;
							case SPACE:
								drawWhiteSpaceEnglish(i*75, j*75);
								break;
							}
						}
						break;
					case RED:{
							switch(gameTheme){
							case PIRATE:
								drawRedEnglish(i*75, j*75);
								break;
							case TRANSFORMER:
								drawRedTransEnglish(i*75, j*75);
								break;
							case SPACE:
								drawRedSpaceEnglish(i*75, j*75);
								break;
							}
						}
						break;
					case WHITEKING:{
							switch(gameTheme){
							case PIRATE:
								drawWhiteKingEnglish(i*75, j*75);
								break;
							case TRANSFORMER:
								drawWhiteKingTransEnglish(i*75, j*75);
								break;
							case SPACE:
								drawWhiteKingSpaceEnglish(i*75, j*75);
								break;
							}
						}
						break;
					case REDKING:{
							switch(gameTheme){
							case PIRATE:
								drawRedKingEnglish(i*75, j*75);
								break;
							case TRANSFORMER:
								drawRedKingTransEnglish(i*75, j*75);
								break;
							case SPACE:
								drawRedKingSpaceEnglish(i*75, j*75);
								break;
							}
						}
						break;
					}
					if(board[i][j].isNextTarget){
						switch(gameTheme){
						case PIRATE:
							drawNextTargetEnglish(i*75, j*75);
							break;
						case TRANSFORMER:
							drawNextTargetTransEnglish(i*75, j*75);
							break;
						case SPACE:
							drawNextTargetSpaceEnglish(i*75, j*75);
							break;							
						}
					}
				}
			}
		}
		switch(board[board_x][board_y].piece){
			case EMPTY:
				if(board[board_x][board_y].chequered){
					switch(gameTheme){
					case PIRATE:
						drawBlackSquareEnglishClicked(board_x*75,board_y*75);
						break;
					case TRANSFORMER:
						drawBlackSquareTransEnglishClicked(board_x*75,board_y*75);
						break;
					case SPACE:
						drawBlackSquareSpaceEnglishClicked(board_x*75,board_y*75);
						break;
					}
				}
				else{
					switch(gameTheme){
					case PIRATE:
						drawWhiteSquareEnglishClicked(board_x*75,board_y*75);
						break;
					case TRANSFORMER:
						drawWhiteSquareTransEnglishClicked(board_x*75,board_y*75);
						break;
					case SPACE:
						drawWhiteSquareSpaceEnglishClicked(board_x*75,board_y*75);
						break;
					}
				}
				break;
			case WHITE:{
					switch(gameTheme){
					case PIRATE:
						drawWhiteEnglishClicked(board_x*75,board_y*75);
						break;
					case TRANSFORMER:
						drawWhiteTransEnglishClicked(board_x*75,board_y*75);
						break;
					case SPACE:
						drawWhiteSpaceEnglishClicked(board_x*75,board_y*75);
						break;
					}
				}
				break;
			case RED:{
					switch(gameTheme){
					case PIRATE:
						drawRedEnglishClicked(board_x*75,board_y*75);
						break;
					case TRANSFORMER:
						drawRedTransEnglishClicked(board_x*75,board_y*75);
						break;
					case SPACE:
						drawRedSpaceEnglishClicked(board_x*75,board_y*75);
						break;
					}
				}
				break;
			case WHITEKING:{
					switch(gameTheme){
					case PIRATE:
						drawWhiteKingEnglishClicked(board_x*75,board_y*75);
						break;
					case TRANSFORMER:
						drawWhiteKingTransEnglishClicked(board_x*75,board_y*75);
						break;
					case SPACE:
						drawWhiteKingSpaceEnglishClicked(board_x*75,board_y*75);
						break;
					}
				}
				break;
			case REDKING:{
					switch(gameTheme){
					case PIRATE:
						drawRedKingEnglishClicked(board_x*75,board_y*75);
						break;
					case TRANSFORMER:
						drawRedKingTransEnglishClicked(board_x*75,board_y*75);
						break;
					case SPACE:
						drawRedKingSpaceEnglishClicked(board_x*75,board_y*75);
						break;
					}
				}
				break;
		}
	}
}

void paintHover(){
	//SIDEBAR LISTENER
	//New Game
	if(10<mouse_y && mouse_y<90 && 610<mouse_x && mouse_x<790){drawNewGameButtonClicked(610,10);} else drawNewGameButton(610,10);
	//Options
	if(100<mouse_y && mouse_y<180 && 610<mouse_x && mouse_x<790 && g_hDialog==NULL){drawOptionButtonClicked(610,100);} else drawOptionButton(610,100);
	//Setting
	if(190<mouse_y && mouse_y<270 && 610<mouse_x && mouse_x<790 && g_hDialog==NULL){drawSettingButtonClicked(610,190);} else drawSettingButton(610,190);
	//About
	if(510<mouse_y && mouse_y<590 && 610<mouse_x && mouse_x<790 && g_hDialog==NULL){drawAboutButtonClicked(610,510);} else drawAboutButton(610,510);
}

void paintStatus(){
	if(gameTurn==PLAYER1)
		drawP1turn(610, 280);
	else 
		drawP2turn(610, 280);
	
	switch(gameWin){
	case NONE:
		break;
	case PLAYER1:
		drawP1win(610,280);
		break;
	case PLAYER2:
		drawP2win(610,280);
		break;
	}
}

//DRAW FUNCTIONS
void drawBackground(int x, int y){BitBlt(g_hdc, x, y, 200, 600, g_hdcMem, 2, 2, SRCCOPY);}
void drawSettingButton(int x, int y){BitBlt(g_hdc, x, y, 180, 80, g_hdcMem, 204, 2, SRCCOPY);}
void drawSettingButtonClicked(int x, int y){BitBlt(g_hdc, x, y, 180, 80, g_hdcMem, 2, 908, SRCCOPY);}
void drawP1turn(int x, int y){BitBlt(g_hdc, x, y, 180, 80, g_hdcMem, 568, 2, SRCCOPY);}
void drawP2turn(int x, int y){BitBlt(g_hdc, x, y, 180, 80, g_hdcMem, 386, 2, SRCCOPY);}
void drawP1win(int x, int y){BitBlt(g_hdc, x, y, 180, 150, g_hdcMem, 2, 756, SRCCOPY);}
void drawP2win(int x, int y){BitBlt(g_hdc, x, y, 180, 150, g_hdcMem, 2, 604, SRCCOPY);}
void drawOptionButton(int x, int y){BitBlt(g_hdc, x, y, 180, 80, g_hdcMem, 204, 84, SRCCOPY);}
void drawOptionButtonClicked(int x, int y){BitBlt(g_hdc, x, y, 180, 80, g_hdcMem, 750, 2, SRCCOPY);}
void drawNewGameButton(int x, int y){BitBlt(g_hdc, x, y, 180, 80, g_hdcMem, 568, 84, SRCCOPY);}
void drawNewGameButtonClicked(int x, int y){BitBlt(g_hdc, x, y, 180, 80, g_hdcMem, 386, 84, SRCCOPY);}
void drawAboutButton(int x, int y){BitBlt(g_hdc, x, y, 180, 80, g_hdcMem, 204, 166, SRCCOPY);}
void drawAboutButtonClicked(int x, int y){BitBlt(g_hdc, x, y, 180, 80, g_hdcMem, 750, 84, SRCCOPY);}

//Normal American
void drawNextTargetAmerican(int x, int y){BitBlt(g_hdc, x, y, 60, 60, g_hdcMem, 420, 402, SRCCOPY);}
void drawBlackSquareAmerican(int x, int y){BitBlt(g_hdc, x, y, 60, 60, g_hdcMem, 358, 325, SRCCOPY);}
void drawBlackSquareAmericanClicked(int x, int y){BitBlt(g_hdc, x, y, 60, 60, g_hdcMem, 281, 941, SRCCOPY);}
void drawWhiteSquareAmerican(int x, int y){BitBlt(g_hdc, x, y, 60, 60, g_hdcMem, 204, 402, SRCCOPY);}
void drawWhiteSquareAmericanClicked(int x, int y){BitBlt(g_hdc, x, y, 60, 60, g_hdcMem, 204, 325, SRCCOPY);}
void drawRedAmerican(int x, int y){BitBlt(g_hdc, x, y, 60, 60, g_hdcMem, 358, 898, SRCCOPY);}
void drawRedAmericanClicked(int x, int y){BitBlt(g_hdc, x, y, 60, 60, g_hdcMem, 358, 836, SRCCOPY);}
void drawRedKingAmerican(int x, int y){BitBlt(g_hdc, x, y, 60, 60, g_hdcMem, 358, 774, SRCCOPY);}
void drawRedKingAmericanClicked(int x, int y){BitBlt(g_hdc, x, y, 60, 60, g_hdcMem, 358, 712, SRCCOPY);}
void drawWhiteAmerican(int x, int y){BitBlt(g_hdc, x, y, 60, 60, g_hdcMem, 358, 402, SRCCOPY);}
void drawWhiteAmericanClicked(int x, int y){BitBlt(g_hdc, x, y, 60, 60, g_hdcMem, 807, 325, SRCCOPY);}
void drawWhiteKingAmerican(int x, int y){BitBlt(g_hdc, x, y, 60, 60, g_hdcMem, 745, 325, SRCCOPY);}
void drawWhiteKingAmericanClicked(int x, int y){BitBlt(g_hdc, x, y, 60, 60, g_hdcMem, 683, 325, SRCCOPY);}

//Normal English
void drawNextTargetEnglish(int x, int y){BitBlt(g_hdc, x, y, 75, 75, g_hdcMem, 512, 248, SRCCOPY);}
void drawBlackSquareEnglish(int x, int y){BitBlt(g_hdc, x, y, 75, 75, g_hdcMem, 358, 325, SRCCOPY);}
void drawBlackSquareEnglishClicked(int x, int y){BitBlt(g_hdc, x, y, 75, 75, g_hdcMem, 281, 941, SRCCOPY);}
void drawWhiteSquareEnglish(int x, int y){BitBlt(g_hdc, x, y, 75, 75, g_hdcMem, 204, 402, SRCCOPY);}
void drawWhiteSquareEnglishClicked(int x, int y){BitBlt(g_hdc, x, y, 75, 75, g_hdcMem, 204, 325, SRCCOPY);}
void drawRedEnglish(int x, int y){BitBlt(g_hdc, x, y, 75, 75, g_hdcMem, 358, 248, SRCCOPY);}
void drawRedEnglishClicked(int x, int y){BitBlt(g_hdc, x, y, 75, 75, g_hdcMem, 281, 248, SRCCOPY);}
void drawRedKingEnglish(int x, int y){BitBlt(g_hdc, x, y, 75, 75, g_hdcMem, 204, 941, SRCCOPY);}
void drawRedKingEnglishClicked(int x, int y){BitBlt(g_hdc, x, y, 75, 75, g_hdcMem, 204, 864, SRCCOPY);}
void drawWhiteEnglish(int x, int y){BitBlt(g_hdc, x, y, 75, 75, g_hdcMem, 204, 479, SRCCOPY);}
void drawWhiteEnglishClicked(int x, int y){BitBlt(g_hdc, x, y, 75, 75, g_hdcMem, 694, 166, SRCCOPY);}
void drawWhiteKingEnglish(int x, int y){BitBlt(g_hdc, x, y, 75, 75, g_hdcMem, 617, 166, SRCCOPY);}
void drawWhiteKingEnglishClicked(int x, int y){BitBlt(g_hdc, x, y, 75, 75, g_hdcMem, 540, 166, SRCCOPY);}

//Transformer American
void drawNextTargetTransAmerican(int x, int y){BitBlt(g_hdc, x, y, 60, 60, g_hdcMem, 358, 960, SRCCOPY);}
void drawBlackSquareTransAmerican(int x, int y){BitBlt(g_hdc, x, y, 60, 60, g_hdcMem, 420, 588, SRCCOPY);}
void drawBlackSquareTransAmericanClicked(int x, int y){BitBlt(g_hdc, x, y, 60, 60, g_hdcMem, 420, 526, SRCCOPY);}
void drawWhiteSquareTransAmerican(int x, int y){BitBlt(g_hdc, x, y, 60, 60, g_hdcMem, 931, 325, SRCCOPY);}
void drawWhiteSquareTransAmericanClicked(int x, int y){BitBlt(g_hdc, x, y, 60, 60, g_hdcMem, 869, 325, SRCCOPY);}
void drawRedTransAmerican(int x, int y){BitBlt(g_hdc, x, y, 60, 60, g_hdcMem, 792, 402, SRCCOPY);}
void drawRedTransAmericanClicked(int x, int y){BitBlt(g_hdc, x, y, 60, 60, g_hdcMem, 730, 402, SRCCOPY);}
void drawRedKingTransAmerican(int x, int y){BitBlt(g_hdc, x, y, 60, 60, g_hdcMem, 420, 464, SRCCOPY);}
void drawRedKingTransAmericanClicked(int x, int y){BitBlt(g_hdc, x, y, 60, 60, g_hdcMem, 916, 402, SRCCOPY);}
void drawWhiteTransAmerican(int x, int y){BitBlt(g_hdc, x, y, 60, 60, g_hdcMem, 497, 325, SRCCOPY);}
void drawWhiteTransAmericanClicked(int x, int y){BitBlt(g_hdc, x, y, 60, 60, g_hdcMem, 435, 325, SRCCOPY);}
void drawWhiteKingTransAmerican(int x, int y){BitBlt(g_hdc, x, y, 60, 60, g_hdcMem, 621, 325, SRCCOPY);}
void drawWhiteKingTransAmericanClicked(int x, int y){BitBlt(g_hdc, x, y, 60, 60, g_hdcMem, 559, 325, SRCCOPY);}

//Transformer English
void drawNextTargetTransEnglish(int x, int y){BitBlt(g_hdc, x, y, 75, 75, g_hdcMem, 435, 248, SRCCOPY);}
void drawBlackSquareTransEnglish(int x, int y){BitBlt(g_hdc, x, y, 75, 75, g_hdcMem, 281, 710, SRCCOPY);}
void drawBlackSquareTransEnglishClicked(int x, int y){BitBlt(g_hdc, x, y, 75, 75, g_hdcMem, 281, 633, SRCCOPY);}
void drawWhiteSquareTransEnglish(int x, int y){BitBlt(g_hdc, x, y, 75, 75, g_hdcMem, 848, 166, SRCCOPY);}
void drawWhiteSquareTransEnglishClicked(int x, int y){BitBlt(g_hdc, x, y, 75, 75, g_hdcMem, 771, 166, SRCCOPY);}
void drawRedTransEnglish(int x, int y){BitBlt(g_hdc, x, y, 75, 75, g_hdcMem, 281, 325, SRCCOPY);}
void drawRedTransEnglishClicked(int x, int y){BitBlt(g_hdc, x, y, 75, 75, g_hdcMem, 897, 248, SRCCOPY);}
void drawRedKingTransEnglish(int x, int y){BitBlt(g_hdc, x, y, 75, 75, g_hdcMem, 281, 556, SRCCOPY);}
void drawRedKingTransEnglishClicked(int x, int y){BitBlt(g_hdc, x, y, 75, 75, g_hdcMem, 281, 479, SRCCOPY);}
void drawWhiteTransEnglish(int x, int y){BitBlt(g_hdc, x, y, 75, 75, g_hdcMem, 932, 84, SRCCOPY);}
void drawWhiteTransEnglishClicked(int x, int y){BitBlt(g_hdc, x, y, 75, 75, g_hdcMem, 932, 2, SRCCOPY);}
void drawWhiteKingTransEnglish(int x, int y){BitBlt(g_hdc, x, y, 75, 75, g_hdcMem, 261, 166, SRCCOPY);}
void drawWhiteKingTransEnglishClicked(int x, int y){BitBlt(g_hdc, x, y, 75, 75, g_hdcMem, 386, 166, SRCCOPY);}

//Space American
void drawNextTargetSpaceAmerican(int x, int y){BitBlt(g_hdc, x, y, 60, 60, g_hdcMem, 854, 402, SRCCOPY);}
void drawBlackSquareSpaceAmerican(int x, int y){BitBlt(g_hdc, x, y, 60, 60, g_hdcMem, 281, 864, SRCCOPY);}
void drawBlackSquareSpaceAmericanClicked(int x, int y){BitBlt(g_hdc, x, y, 60, 60, g_hdcMem, 281, 787, SRCCOPY);}
void drawWhiteSquareSpaceAmerican(int x, int y){BitBlt(g_hdc, x, y, 60, 60, g_hdcMem, 204, 248, SRCCOPY);}
void drawWhiteSquareSpaceAmericanClicked(int x, int y){BitBlt(g_hdc, x, y, 60, 60, g_hdcMem, 925, 166, SRCCOPY);}
void drawRedSpaceAmerican(int x, int y){BitBlt(g_hdc, x, y, 60, 60, g_hdcMem, 358, 650, SRCCOPY);}
void drawRedSpaceAmericanClicked(int x, int y){BitBlt(g_hdc, x, y, 60, 60, g_hdcMem, 358, 588, SRCCOPY);}
void drawRedKingSpaceAmerican(int x, int y){BitBlt(g_hdc, x, y, 60, 60, g_hdcMem, 358, 526, SRCCOPY);}
void drawRedKingSpaceAmericanClicked(int x, int y){BitBlt(g_hdc, x, y, 60, 60, g_hdcMem, 358, 464, SRCCOPY);}
void drawWhiteSpaceAmerican(int x, int y){BitBlt(g_hdc, x, y, 60, 60, g_hdcMem, 668, 402, SRCCOPY);}
void drawWhiteSpaceAmericanClicked(int x, int y){BitBlt(g_hdc, x, y, 60, 60, g_hdcMem, 606, 402, SRCCOPY);}
void drawWhiteKingSpaceAmerican(int x, int y){BitBlt(g_hdc, x, y, 60, 60, g_hdcMem, 544, 402, SRCCOPY);}
void drawWhiteKingSpaceAmericanClicked(int x, int y){BitBlt(g_hdc, x, y, 60, 60, g_hdcMem, 482, 402, SRCCOPY);}

//Space English
void drawNextTargetSpaceEnglish(int x, int y){BitBlt(g_hdc, x, y, 75, 75, g_hdcMem, 281, 402, SRCCOPY);}
void drawBlackSquareSpaceEnglish(int x, int y){BitBlt(g_hdc, x, y, 75, 75, g_hdcMem, 281, 864, SRCCOPY);}
void drawBlackSquareSpaceEnglishClicked(int x, int y){BitBlt(g_hdc, x, y, 75, 75, g_hdcMem, 281, 787, SRCCOPY);}
void drawWhiteSquareSpaceEnglish(int x, int y){BitBlt(g_hdc, x, y, 75, 75, g_hdcMem, 204, 148, SRCCOPY);}
void drawWhiteSquareSpaceEnglishClicked(int x, int y){BitBlt(g_hdc, x, y, 75, 75, g_hdcMem, 204, 325, SRCCOPY);}
void drawRedSpaceEnglish(int x, int y){BitBlt(g_hdc, x, y, 75, 75, g_hdcMem, 204, 787, SRCCOPY);}
void drawRedSpaceEnglishClicked(int x, int y){BitBlt(g_hdc, x, y, 75, 75, g_hdcMem, 204, 710, SRCCOPY);}
void drawRedKingSpaceEnglish(int x, int y){BitBlt(g_hdc, x, y, 75, 75, g_hdcMem, 204, 633, SRCCOPY);}
void drawRedKingSpaceEnglishClicked(int x, int y){BitBlt(g_hdc, x, y, 75, 75, g_hdcMem, 204, 556, SRCCOPY);}
void drawWhiteSpaceEnglish(int x, int y){BitBlt(g_hdc, x, y, 75, 75, g_hdcMem, 820, 248, SRCCOPY);}
void drawWhiteSpaceEnglishClicked(int x, int y){BitBlt(g_hdc, x, y, 75, 75, g_hdcMem, 743, 248, SRCCOPY);}
void drawWhiteKingSpaceEnglish(int x, int y){BitBlt(g_hdc, x, y, 75, 75, g_hdcMem, 666, 248, SRCCOPY);}
void drawWhiteKingSpaceEnglishClicked(int x, int y){BitBlt(g_hdc, x, y, 75, 75, g_hdcMem, 589, 248, SRCCOPY);}

BOOL CALLBACK AboutProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
{
    switch(Message)
    {
        case WM_INITDIALOG:

        return TRUE;
        case WM_COMMAND:
            switch(LOWORD(wParam))
            {
                case IDOK:
                    EndDialog(hwnd, IDOK);
					g_hDialog = NULL;
                break;
                case IDCANCEL:
                    EndDialog(hwnd, IDCANCEL);
					g_hDialog = NULL;
                break;
            }
        break;
        default:
            return FALSE;
    }
    return TRUE;
}

void createOptionDialog(HWND hwnd){
	g_hDialog = CreateDialog(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_OPTIONS),
	hwnd, OptionsProc);
	if(gameAlgorithm==GREEDYBYKING){
		HWND greedybykingRadio = GetDlgItem(g_hDialog, IDC_GREEDYBYKING);
		SendMessage(greedybykingRadio, BM_SETCHECK, BST_CHECKED, 0);
	} else {
		HWND greedybyeatingRadio = GetDlgItem(g_hDialog, IDC_GREEDYBYEATING);
		SendMessage(greedybyeatingRadio, BM_SETCHECK, BST_CHECKED, 0);
	}
	HWND hWndGameMode = CreateWindow("COMBOBOX",
								NULL,
								WS_CHILD | WS_VISIBLE | WS_TABSTOP | CBS_DROPDOWN,
								30, 40, 180, 600,
								g_hDialog,
								(HMENU)IDC_GAMEMODE,
								g_hInstance,
								NULL);
	const char *GameMode[] = {"Player vs. Player", "Player vs. Computer", "Computer vs. Computer"};
	for(int Count = 0; Count < 3; Count++)
	{
		SendMessage(hWndGameMode,
					CB_ADDSTRING,
					0,
					reinterpret_cast<LPARAM>((LPCTSTR)GameMode[Count]));
	}
	SendMessage(hWndGameMode, CB_SETCURSEL, gameMode, 0);

	HWND hWndGameSpeed = CreateWindow("COMBOBOX",
								NULL,
								WS_CHILD | WS_VISIBLE | WS_TABSTOP | CBS_DROPDOWN,
								30, 75, 180, 600,
								g_hDialog,
								(HMENU)IDC_GAMESPEED,
								g_hInstance,
								NULL);
	const char *GameSpeed[] = {"Slow", "Normal", "Fast"};
	for(int Count = 0; Count < 3; Count++)
	{
		SendMessage(hWndGameSpeed,
					CB_ADDSTRING,
					0,
					reinterpret_cast<LPARAM>((LPCTSTR)GameSpeed[Count]));
	}
	SendMessage(hWndGameSpeed, CB_SETCURSEL, gameSpeed, 0);

	HWND hWndGameRule = CreateWindow("COMBOBOX",
								NULL,
								WS_CHILD | WS_VISIBLE | WS_TABSTOP | CBS_DROPDOWN,
								30, 110, 180, 600,
								g_hDialog,
								(HMENU)IDC_GAMERULE,
								g_hInstance,
								NULL);
	SendMessage(hWndGameRule,CB_ADDSTRING,0,reinterpret_cast<LPARAM>((LPCTSTR)"International"));
	SendMessage(hWndGameRule,CB_ADDSTRING,0,reinterpret_cast<LPARAM>((LPCTSTR)"English"));
	SendMessage(hWndGameRule, CB_SETCURSEL, gameRule, 0);

	if(g_hDialog != NULL)
		ShowWindow(g_hDialog, SW_SHOW);
	else
		MessageBox(hwnd, "CreateDialog returned NULL", "Warning!",  
			MB_OK | MB_ICONINFORMATION);
}

BOOL CALLBACK OptionsProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
{
    switch(Message)
    {
        case WM_COMMAND:
            switch(LOWORD(wParam))
            {
                case IDC_GREEDYBYEATING:
					temp_gameAlgorithm=GREEDYBYEATING;
                break;
                case IDC_GREEDYBYKING:
					temp_gameAlgorithm=GREEDYBYKING;
                break;
				case IDC_GAMEMODE:
					switch(HIWORD(wParam)){
					case CBN_CLOSEUP:
						HWND hWndGameMode = GetDlgItem(hwnd, IDC_GAMEMODE);
						temp_gameMode = SendMessage(hWndGameMode, CB_GETCURSEL, (WORD)0, 0L);
						break;
					}               
                break;
				case IDC_GAMESPEED:
					switch(HIWORD(wParam)){
					case CBN_CLOSEUP:
						HWND hWndGameSpeed = GetDlgItem(hwnd, IDC_GAMESPEED);
						temp_gameSpeed = SendMessage(hWndGameSpeed, CB_GETCURSEL, (WORD)0, 0L);
						break;
					}
				case IDC_GAMERULE:
					switch(HIWORD(wParam)){
					case CBN_CLOSEUP:
						HWND hWndGameRule = GetDlgItem(hwnd, IDC_GAMERULE);
						temp_gameRule = SendMessage(hWndGameRule, CB_GETCURSEL, (WORD)0, 0L);
						break;
					} 
                break;
				case IDOK1:
					gameRule=temp_gameRule;
					gameSpeed=temp_gameSpeed;
					gameMode=temp_gameMode;
					gameAlgorithm=temp_gameAlgorithm;
                    MessageBox(hwnd, "Your Setting is Saved!\r\nGame will be restarting.", "", 
                        MB_OK | MB_ICONEXCLAMATION);
					DestroyWindow(g_hDialog);
					g_hDialog = NULL;
					initiatedummy();
					InvalidateRect(g_hwnd, NULL, false);
					UpdateWindow(g_hwnd);
				break;
                case IDCANCEL:
					DestroyWindow(g_hDialog);
					g_hDialog = NULL;
                break;
            }
        break;
        default:
            return FALSE;
    }
    return TRUE;
}

void createSettingDialog(HWND hwnd){
	g_hDialog = CreateDialog(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_SETTING),
		hwnd, SettingProc);
	if(isSoundOn){
		HWND soundOnRadio = GetDlgItem(g_hDialog, IDC_SOUNDON);
		SendMessage(soundOnRadio, BM_SETCHECK, BST_CHECKED, 0);
	} else {
		HWND soundOffRadio = GetDlgItem(g_hDialog, IDC_SOUNDOFF);
		SendMessage(soundOffRadio, BM_SETCHECK, BST_CHECKED, 0);
	}

	HWND hWndGameTheme = CreateWindow("COMBOBOX",
								NULL,
								WS_CHILD | WS_VISIBLE | WS_TABSTOP | CBS_DROPDOWN,
								30, 40, 180, 600,
								g_hDialog,
								(HMENU)IDC_GAMETHEME,
								g_hInstance,
								NULL);
	const char *GameTheme[] = {"Pirate", "Transformer", "Space"};
	for(int Count = 0; Count < 3; Count++)
	{
		SendMessage(hWndGameTheme,
					CB_ADDSTRING,
					0,
					reinterpret_cast<LPARAM>((LPCTSTR)GameTheme[Count]));
	}
	SendMessage(hWndGameTheme, CB_SETCURSEL, gameTheme, 0);

	HWND hWndGameSound = CreateWindow("COMBOBOX",
								NULL,
								WS_CHILD | WS_VISIBLE | WS_TABSTOP | CBS_DROPDOWN,
								30, 75, 180, 600,
								g_hDialog,
								(HMENU)IDC_GAMESOUND,
								g_hInstance,
								NULL);
	const char *GameSound[] = {"Pirate Music", "Transformer Music", "Space Music"};
	for(int Count = 0; Count < 3; Count++)
	{
		SendMessage(hWndGameSound,
					CB_ADDSTRING,
					0,
					reinterpret_cast<LPARAM>((LPCTSTR)GameSound[Count]));
	}
	SendMessage(hWndGameSound, CB_SETCURSEL, gameSound, 0);

	if(g_hDialog != NULL)
		ShowWindow(g_hDialog, SW_SHOW);
	else
		MessageBox(hwnd, "CreateDialog returned NULL", "Warning!",  
			MB_OK | MB_ICONINFORMATION);
}

BOOL CALLBACK SettingProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
{
    switch(Message)
    {
        case WM_COMMAND:
            switch(LOWORD(wParam))
            {
				case IDC_GAMETHEME:
					switch(HIWORD(wParam)){
					case CBN_CLOSEUP:
						HWND hWndGameTheme = GetDlgItem(hwnd, IDC_GAMETHEME);
						temp_gameTheme = SendMessage(hWndGameTheme, CB_GETCURSEL, (WORD)0, 0L);
						HWND hWndGameSound = GetDlgItem(hwnd, IDC_GAMESOUND);
						temp_gameSound = SendMessage(hWndGameSound, CB_SETCURSEL, temp_gameTheme, 0);
						break;
					}
				break;
				case IDC_GAMESOUND:
					switch(HIWORD(wParam)){
					case CBN_CLOSEUP:
						HWND hWndGameSound = GetDlgItem(hwnd, IDC_GAMESOUND);
						temp_gameSound = SendMessage(hWndGameSound, CB_GETCURSEL, (WORD)0, 0L);
						break;
					}
				break;
                case IDC_SOUNDON:
					temp_isSoundOn=true;
                break;
                case IDC_SOUNDOFF:
					temp_isSoundOn=false;
                break;
				case IDOK2:
					
					if(gameTheme!=temp_gameTheme){
						gameTheme=temp_gameTheme;
						InvalidateRect(g_hwnd, NULL, false);
						UpdateWindow(g_hwnd);
					}
					
					if(gameSound!=temp_gameSound){
						gameSound=temp_gameSound;
						initiateMusic();
					}

					if(temp_isSoundOn!=isSoundOn){
						isSoundOn=temp_isSoundOn;
						if(isSoundOn) initiateMusic(); else PlaySound(NULL, 0, 0);
					}
					DestroyWindow(g_hDialog);
					g_hDialog = NULL;
				break;
                case IDCANCEL:
					DestroyWindow(g_hDialog);
					g_hDialog = NULL;
                break;
            }
        break;
        default:
            return FALSE;
    }
    return TRUE;
}

void initiateMusic(){	
	//initiate music
	switch(gameSound){
		case PIRATE:PlaySound(TEXT("sound/pirate.wav"), NULL, SND_FILENAME| SND_ASYNC | SND_LOOP);break;
		case TRANSFORMER:PlaySound(TEXT("sound/transformer.wav"), NULL, SND_FILENAME| SND_ASYNC | SND_LOOP);break;
		case SPACE:PlaySound(TEXT("sound/space.wav"), NULL, SND_FILENAME| SND_ASYNC | SND_LOOP);break;
	}
}

void initiatedummy(){
	//initiate board
	for(int i=0; i<10; i++){
		for(int j=0; j<10; j++){
			board[i][j].chequered = ((i+j) % 2 == 0);
			board[i][j].piece = EMPTY;
			board[i][j].isNextTarget = false;
		}
	}
	if(gameRule==AMERICAN){
		//initiate piece
		for(int i=0; i<10; i++){
			for(int j=0; j<4; j++){
				if(board[i][j].chequered)
					board[i][j].piece = RED;
			}
			for(int j=6; j<10; j++){
				if(board[i][j].chequered)
					board[i][j].piece = WHITE;
			}
		}
	}else{
		//initiate piece
		for(int i=0; i<8; i++){
			for(int j=0; j<3; j++){
				if(board[i][j].chequered)
					board[i][j].piece = RED;
			}
			for(int j=5; j<8; j++){
				if(board[i][j].chequered)
					board[i][j].piece = WHITE;
			}
		}
	}

	board[0][0].piece=REDKING;
	board[0][6].piece=WHITEKING;

	initiateMusic();
}